package com.dsl.comp;

import com.dsl.perfs.ExprEvalutorHelper;

import java.util.Map;
import java.util.Random;
import java.util.TreeMap;

/**
 * https://www.cnblogs.com/mumuxinfei/p/8474375.html
 *
 * @author evoup
 */
public class AntlrPerf {

    public static void main(String[] args) {

        String boolExpr = "1 && 2 || 3 || 4 && (5 || 6)";

        int iterNums = 1000000;
        long randomSeed = 10001L;
        Random random = new Random(randomSeed);

        long beg = System.currentTimeMillis();
        for (int i = 0; i <= iterNums; i++) {
            Map<String, Boolean> params = new TreeMap<>();
            params.put("1", random.nextBoolean());
            params.put("2", random.nextBoolean());
            params.put("3", random.nextBoolean());
            params.put("4", random.nextBoolean());
            params.put("5", random.nextBoolean());
            params.put("6", random.nextBoolean());
            ExprEvalutorHelper.exec(boolExpr, params);
        }
        long end = System.currentTimeMillis();
        System.out.println(String.format("total consume: %dms", end - beg));

    }

}
